package lab01;

import java.util.Scanner;

public class Test12 {

    public static void main(String args[]) {

        int number = 0, n5, n4, n3, n2, n1;

        System.out.println("请输入一个整数：");

        Scanner input = new Scanner(System.in);

        number = input.nextInt();

        //判断number在1至99999之间的条件 
        if (number >= 1 || number <= 99999){

            //计算number的最高位（万位）n5
            n5 = number / 10000;

            //计算number的千位n4 
            n4 = number % 10000 / 1000;

            //计算number的百位n3
            n3 = number % 10000 % 1000 / 100;

            //计算number的十位n2  
            n2 = number % 100 / 10;

            //计算number的个位n1
            n1 = number % 10;

            //判断number是5位数的条件
            if (n5 >= 1 && n5 <= 9){

                System.out.println(number + "是5位数");

                //判断number是回文数的条件
                if (n1 == n5 && n2 == n4){

                    System.out.println(number + "是回文数");

                }
                else {
                    System.out.println(number + "不是回文数");
                }
            }

            //判断number是4位数的条件
            else if (n5 == 0 && (n4 >= 1 && n5 <= 9)){

                System.out.println(number + "是4位数");

                //判断number是回文数的条件
                if (n1 == n4 && n2 == n3) {

                    System.out.println(number + "是回文数");
                }
                else {
                    System.out.println(number + "不是回文数");
                }
            }

            //判断number是3位数的条件 
            else if (n5 == 0 && n4 == 0 && n3 != 0){

                System.out.println(number + "是3位数");

                //判断number是回文数的条件 
                if (n1 == n3){

                    System.out.println(number + "是回文数");
                }

                else {
                    System.out.println(number + "不是回文数");
                }
            }

            else if (n2 != 0) {

                System.out.println(number + "是二位数");

                    if (n1 == n2) {

                    System.out.println(number + "是回文数");

                }
                else {

                    System.out.println(number + "不是回文数");
                }
            }
            else if (n1 != 0) {

                System.out.println(number + "是一位数");

                System.out.println(number + "是回文数");
            }
        }

        else {

            System.out.printf("\n%d不在1至99999之间", number);
        }
    }

}
